package net.itfenxiang.mybatisplus.controller;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import lombok.AllArgsConstructor;
import net.itfenxiang.mybatisplus.entity.CardFaceValueCompany;
import net.itfenxiang.mybatisplus.entity.UserEntity;
import net.itfenxiang.mybatisplus.entity.WithdrawRecord;
import net.itfenxiang.mybatisplus.query.CompanyQuery;
import net.itfenxiang.mybatisplus.service.ICardFaceValueCompanyService;
import net.itfenxiang.mybatisplus.service.IWithdrawRecordService;
import net.itfenxiang.mybatisplus.service.UserService;
import net.itfenxiang.mybatisplus.utils.PageResult;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @description: 用户列表
 * @author: 墨凡
 * @date: 2024/4/28 16:16
 * @version: 1.0
 */
@RestController
@RequestMapping("sys")
@AllArgsConstructor
public class UserController {

    private final UserService userService;
    private final IWithdrawRecordService recordService;
    private final ICardFaceValueCompanyService faceValueCompanyService;

    @GetMapping("user")
    public UserEntity getUser(@RequestParam("id") Long id){
        return userService.getUser(id);
    }

    @GetMapping("userList")
    public List<UserEntity> getUserList(){
        return userService.getUserList();
    }

    @GetMapping("config")
    public String getConfig(){
        return "config";
    }

    @PostMapping("update")
    public void updateUser(@RequestBody UserEntity user){
        userService.update(user);
    }

    @GetMapping("pageRecord")
    public Page<WithdrawRecord> getsPage(){
        return recordService.page();
    }

    @PostMapping("page")
    public PageResult<CardFaceValueCompany> page(@RequestBody CompanyQuery query){
        return faceValueCompanyService.page(query);
    }
}
